package tests;

import static org.junit.Assert.*;

import java.sql.Timestamp;
import java.util.Date;



import model.Filter;
import model.FilterBuilder;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
 * This class tests the FilterBuilder class
 * 
 * @author buthainahaldosary
 * @since June 5, 2013
 *
 * @version $Revision: 1.0 $
 */
public class TestFilterBuilder {

	 FilterBuilder flBuilder,result,flb;
	 Filter fl;
	 Date date;
	 Timestamp currentTime;
	 
	 /**
		 * This method is called before every test case to setup a new filter builder, date and current time timestamp.
		 */
	@Before
	public void setUp()
	{
		flBuilder=new FilterBuilder();
		date= new Date();
		currentTime=(new Timestamp(date.getTime()));
	}
	
	/**
	 * This method is called after every test case to tear down the EmailBuilder and force garbage collection.
	 */
	@After
	public void tearDown()
	{
		flBuilder=null;
		result=null;
		System.gc();
		
		
	}

	/**
	 * This test case tests the setUserId() method 
	 */
	@Test
	public void testSetUserId() {
		
		
			result=flBuilder.setUserId(2);
			assertEquals(2,result.getUserId());
		
	}
	/**
	 * This test case tests the setId() method 
	 */
	@Test
	public void testId() {
		
		
			flBuilder.setId(3);
			assertEquals(3,flBuilder.getId());
		
	}
	/**
	 * This test case tests the set title method
	 */
	@Test
	public void testSetTitle() {
		result=flBuilder.setTitle("new title");
		assertEquals("new title", result.getTitle());
	}
	/**
	 * This test case tests the set to method
	 */
	@Test
	public void testSetTo() {
		result=flBuilder.setTo("new to");
		assertEquals("new to", result.getTo());
	}
	/**
	 * This test case tests the set from method
	 */
	@Test
	public void testSetFrom() {
		result=flBuilder.setFrom("new from");
		assertEquals("new from", result.getFrom());
	}
	/**
	 * This test case tests the set body method
	 */
	@Test
	public void testSetBody() {
		result=flBuilder.setBody("new body");
		assertEquals("new body", result.getBody());
	}
	/**
	 * This test case tests the set folder id method
	 */
	@Test
	public void testSetFolderId() {
		result=flBuilder.setFolderId(2);
		assertEquals(2, result.getFolderId());
	}
	/**
	 * This test case tests the build method
	 */
	@Test
	public void testBuild() {
		
		fl=flBuilder.setBody("body").setFolderId(3).setFrom("from").setTitle("title").setTo("to").setUserId(4).build();
		assertNotNull(fl);
	}

	

}
